<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="zh-CN">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>登录 | smart</title>
  <link href="/SmartCommunity/css/pc/bootstrap.css" rel="stylesheet">
  	<link href="/SmartCommunity/css/pc/main.css" rel="stylesheet">
  <link rel="stylesheet" href="/SmartCommunity/css/pc/application-49d5e02c.css" />
</head>
<body class="account" id="login">
  <ul class="bg-slideshow">
    <li>
      <span>Image 01</span>
    </li>
    <li>
      <span>Image 02</span>
    </li>
    <li>
      <span>Image 03</span>
    </li>
    <li>
      <span>Image 04</span>
    </li>
    <li>
      <span>Image 05</span>
    </li>
  </ul>
    <div class="login-modal">
    <div class="login-modal-dialog">
      <div class="login-onboard">
          <div class="login-modal-dialog-heading">
              <a  title="回到主页" id="login-logo">SMART</a>
          </div>
         <div class="login-modal-dialog-form">
              <form class="form-sign" onsubmit="return check()">
                  <div class="form-group ob-input-w-icon">
                     <label>找回密码手机号</label>
                      <input type="text" class="form-control" id="phone"name="phone" placeholder="手机号"  autofocus="autofocus" />
                  </div>
                  <div class="form-group ob-input-w-icon">
                      <label class="forget_num">验证码</label>
                      <input type="password" class="forget_input_num" name="password" placeholder="验证码" required="required" />
                      <input class="forget_btn "  type="button" value="获取验证码" />
                  </div>
                
                  <button class="btn btn-primary btn-block" id="forget_submit">提交</button>
              </form>              
          </div>
      </div>
    </div>
  </div>
  <script src="/SmartCommunity/js/pc/jquery.js"></script>
  <script>
  $(".forget_btn").click(function(){
	  var phone=$("#phone").val();
	  var regu = /^[1][0-9][0-9]{9}$/;
	  var re = new RegExp(regu);
	  	if (!re.test(phone)) { 
	  		alert("请输入合法的手机号");
	  		$("#phone").focus();
	  	}
	  	else{
	  		$.ajax({
	  			type: "POST",
	  			url: "/SmartCommunity/?phone="+phone,
	  			contentType: "application/json; charset=utf-8",
	  			success: function(data){	
	  				var arr=eval("("+data+")");
	  				if(arr.verify==1){
	  					$("#btn").attr("disabled", true);
	  					get_verify(60);
	  				}
	  				else{
	  					alert("请输入正确的登录手机号");
	  				}
	  			},
	  			error: function(){
	  				alert("error");	
	  				//get_verify(60);
	  			} 
	  		}); 
	  		
	  	}
  });
  function get_verify(e){
		if(e==0){
			$(".forget_btn").val("获取验证码");
			$(".forget_btn").attr("disabled", false);
			clearTimeout(f);
		}
		else{
		$(".forget_btn").val("等待"+ e +"秒重发");
		e--;
		var f =setTimeout('get_verify('+e+')',1000);
		}
	}
 function check(){
	  var phone=$("#phone").val();
	  //alert(phone);
	  var vertify=$(".forget_input_num").val();
	  $.ajax({
			type: "POST",
			url: "/SmartCommunity/?phone="+phone+"&vertify="+vertify,
			contentType: "application/json; charset=utf-8",
			success: function(data){	
				
				if(data=="true"){
					alert("密码修改成功");
					window.location.href="/SmartCommunity/views/pc/login.html";
				}
				else{
					alert("请输入正确的验证码");
				}
			},
			error: function(){
				alert("error");	
				//window.location.href="/SmartCommunity/views/pc/login.html";
			} 
		}); 
 }
	  
  
  </script>
</body>
</html>
